package com.anivia.common.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;


/**
 * 脱敏类型
 *
 * @author wangj
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum DesensitizedTypeEnum implements BaseEnum {
    /**
     * 姓名
     */
    CHINESE_NAME(1, "中文名称"),
    /**
     * 座机
     */
    FIXED_PHONE(2, "座机号码"),
    /**
     * 身份证
     */
    ID_CARD(3, "身份证号"),
    /**
     * 手机号
     */
    PHONE(4, "手机号码"),
    ;


    @EnumValue
    private Integer code;
    private String desc;

    public String toString() {
        return name() + "-" + getDesc();
    }

    public static DesensitizedTypeEnum getByCode(Integer code) {
        for (DesensitizedTypeEnum enumItem : values()) {
            if (enumItem.code.equals(code)) {
                return enumItem;
            }
        }
        return null;
    }
}
